<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <script>
      var isValid = function (s) {
        const stack = [];
        const map = new Map();
        const mapper = {
          "{": "}",
          "[": "]",
          "(": ")",
        };
        for (let str of s) {
          if (mapper[str]) {
            stack.push(str);
          } else {
            if (mapper[stack.pop()] !== str) {

              return false;
            }
          }
        }
        return !stack.length;
      };

      console.log(isValid("{[[()]]}"));
    </script>
  </body>
</html>
